import { ElMessage } from "element-plus";

// 防抖函数
function debounce(fun: Function, time: any) {
  let timer: any = null
  return function (...args: any) {
    if (timer) {
      clearTimeout(timer)
    }
    timer = setTimeout(() => {
      fun(...args)
    }, time)
  }
}

// 时间转换
const timeChange = (data: any) => {
  const date = new Date(data)

  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()

  const h = date.getHours()
  const m = date.getMinutes()
  return `${year}/${month}/${day} ${h}:${m}`
}

export {
  debounce,
  timeChange
}